<?php
session_start();
include('includes/db/sql.functions.php');


$source= $_POST['source'];
$hwsname= $_POST['hwsname'];

$errores=Array();
$values=array();

$gen_name= $_POST['g_name'.$id];
if($gen_name == ""){
	$errores[name]= "Empty name";

}else{
	$values[name]=$gen_name;

}

$gen_spice= $_POST['g_spice'.$id];
if($gen_spice == ""){
	$errores[genSpice]= "Empty Species";
}else{
	$values[spice]=$gen_spice;
}

$gen_codSus= $_POST['bb_g_codSus'.$id];
if($gen_codSus == ""){
	$errores[codSus]= "Empty Substance cod";
}else{
	$values[codSus]=$gen_codSus;
}

$gen_linkbb= $_POST['bb_g_linkBB'.$id];
if($gen_linkbb == ""){
	//$errores[BBlink]= "Empty BioBrick link";
}else{
	$values[linkbb]=$gen_linkbb;
}

$gen_linkbd= $_POST['bb_g_linkBD'.$id];
if($gen_linkbd == ""){
	//$errores[BDlink]= "Empty BioBrick link";
}else{
	$values[linkbd]=$gen_linkbd;
}

$gen_fasta= $_POST['bb_g_fasta'.$id];
if($gen_fasta == ""){
	$errores[fasta]= "Empty fasta sequence";
}else{
	$values[fasta]=$gen_fasta;
}

if(empty($errores)){
	$_SESSION["genForm"]["errores"]="";

	$query=add_gen($gen_name, $gen_spice, $gen_codSus,$gen_linkbb,$gen_linkbd,$gen_fasta);
	if($query!=-9){
		if($hwsname){
			$query2=add_gen_hws( $gen_name, $hwsname);
			if($query2!=-9){
				header("Location: wires.php?success=gen");
			}
				
		}else{
			header("Location: wires.php?success=gen");
		}

	}
	

}else{

	$_SESSION["genForm"]["errores"]=$errores;
	$_SESSION["genForm"]["values"]=$values;
	Header("Location:".$source);
}


?>
